package cn.edu.tsinghua.thss.alg.closestpair;

/**
 * Defines the point.
 * 
 * @author
 * 
 */
public class Point {
	/** the x and y coordinate */
	double x, y;
	/** the index of the point after sorting to x */
	int index_x;

	/**
	 * Get the x coordinate
	 * 
	 * @return x
	 */
	public double getX() {
		return x;
	}

	/**
	 * Set the x coordinate
	 * 
	 * @param x
	 */
	public void setX(double x) {
		this.x = x;
	}

	/**
	 * Get the y coordinate
	 * 
	 * @return y
	 */
	public double getY() {
		return y;
	}

	/**
	 * Set the y coordinate
	 * 
	 * @param y
	 */
	public void setY(double y) {
		this.y = y;
	}

	/**
	 * Default constructor
	 */
	public Point() {
		x = 0;
		y = 0;
	}

	/**
	 * Initializes the point
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 */
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	/**
	 * Initializes the point
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 * @param index_x
	 *            the index of the point after sorted to x
	 */
	public Point(double x, double y, int index_x) {
		this.x = x;
		this.y = y;
		this.index_x = index_x;
	}

	public String toString() {
		return "(" + this.x + "," + this.y + ")";
	}

	@Override
	public int hashCode() {
		return (int) (x * y);
	}

	@Override
	public boolean equals(Object obj) {
		return x == ((Point) (obj)).x && y == ((Point) (obj)).y;
	}

}
